<template>
    <div class="home">
        <el-container>
            <LeftHeader  class="headeerleft" :isCollapse="isCollapse"></LeftHeader>
            <el-container>
                <el-header class="nav">
                        <div class="left">
                            <div class="topleftbox"  @click="btn()">
                            <el-icon v-show="isCollapse" class="icon"><Expand /></el-icon>
                            <el-icon v-show="!isCollapse" class="icon"><Fold /></el-icon>
                        </div>
                        <el-breadcrumb separator="/" class="bread">
                            <el-breadcrumb-item :to="{ path: '/home' }">首页</el-breadcrumb-item>
                            <el-breadcrumb-item v-if="route.meta.title!=='首页'&&route.meta.parent">{{ route.meta.parent }}</el-breadcrumb-item>
                            <el-breadcrumb-item v-if="route.meta.title!=='首页'&&route.meta.title">{{ route.meta.title }}</el-breadcrumb-item>
                        </el-breadcrumb>
                    </div>
                    <div class="right">
                        <div class="Rleft">
                            <el-icon @click="screen()" v-show="flag==false"><FullScreen /></el-icon>
                            <el-icon @click="screen()" v-show="flag==true"><CloseBold /></el-icon>
                        </div>
                        <div class="Rright">
                            <el-dropdown  el-dropdown trigger="click">
                                <span class="el-dropdown-link">
                                    admin<el-icon class="el-icon--right"><arrow-down /></el-icon>
                                </span>
                                <template #dropdown>
                                    <el-dropdown-menu>
                                        <el-dropdown-item>个人信息修改</el-dropdown-item>
                                        <el-dropdown-item  divided @click="esc">退出登录</el-dropdown-item>
                                    </el-dropdown-menu>
                                </template>
                            </el-dropdown>
                        </div>
                    </div>
                </el-header>
                <el-main>
                    <router-view v-slot="{ Component }">
                        <keep-alive>
                        <component :is="Component" :key="$route.name" v-if="$route.meta.keepAlive" />
                        </keep-alive>
                        <component :is="Component" :key="$route.name" v-if="!$route.meta.keepAlive" />
                    </router-view>
                </el-main>
            </el-container>
        </el-container>
    </div>
</template>

<script setup lang="ts">
    import LeftHeader from "../components/LeftHeader.vue"
    import { ref,Ref } from "vue";
    import { useRoute, useRouter } from 'vue-router'
    const router = useRouter()
    let route = useRoute()
    console.log(route.meta)
    const isCollapse = ref(false)
    const btn = () => {
    isCollapse.value = !isCollapse.value
    }
    let flag: Ref<boolean | null> = ref(false)
 
    const screen=()=> {
        let element = document.documentElement;
        flag.value = document.fullscreenElement === null ? false :true
        console.log(flag.value)
        if (flag.value) {
            if (document.exitFullscreen) {
                document.exitFullscreen();
            }
        } else {
            if (element.requestFullscreen) {
                element.requestFullscreen();
            }
        }
        flag.value = !flag.value
    }
    const esc = () => {
        sessionStorage.clear();
        router.push('/login');
    }
</script>

<style scoped lang="less">
.home{
    height: 100%;
}
.el-container{
    height: 100%;
}
.headeerleft {
  height: 100%;
  background-color: #545c64;
}
.nav{
    width: 100%;
    display: flex;
    justify-content: space-between;
    height: 50px;
    box-shadow: 0 1px 4px rgba(0,21,41,.08);
    .left{ 
        float: left;
        display: flex;
        .bread{
            margin-left: 8px;
            line-height: 50px;
        }
        .topleftbox{
            width: 50px;
            height: 50px;
            line-height: 60px;
            text-align: center;
            .icon{
                font-size: 25px;
            }
        }
    }
    .right{
        display: flex;
        font-size: 18px;
        .Rleft{
            line-height: 50px;
            margin-right: 30px;
        }
        .Rright{
            margin-top: 10px;
            .el-dropdown-link{
                font-size: 18px;
            }
        }
    }
}

.el-header{
    padding: 0;
}
.el-main{
    padding: 20px;
}
</style>